<?php namespace App\Http\Controllers;

use App\Comic;
use App\ComicImgs;
use Illuminate\Http\Request;
use App\Content;


class HomeController extends Controller
{
    public function content(Request $request){
        $id = !is_null($request->get('id'))?$request->get('id'):0;
        $content = Content::whereId($id)->first();
//        echo "<pre>";
//        print_r($content);
//        die();

        return view("content",['content' => $content]);
    }

    public function manhualist(Request $request){

        $allComics = Comic::orderBy("id","desc")->get();
//        if(count($allComics) > 0){
//            foreach ($allComics as $comic){
//                $comicImgs = ComicImgs::whereComicId($comic->id)->orderBy("id","asc")->get();
//                $comic->img_list = $comicImgs;
//            }
//        }

        return view("manhua",["comics"=>$allComics]);
    }

    public function manhuaImgList(Request $request){
        $id = $request->get("id");

        $allComics = ComicImgs::whereComicId($id)->orderBy("id","desc")->get();


        return view("manhua-imgs",["comics"=>$allComics]);
    }
}